package com.xzkj.ad

import android.app.Activity
import com.ifmvo.togetherad.core.helper.AdHelperInter
import com.ifmvo.togetherad.core.listener.InterListener

object InterAd {
    val tag = "InterAd"
    var adHelperInter: AdHelperInter ?= null

     fun load(activity: Activity,
              listener: InterListener? = null) {
         adHelperInter = AdHelperInter(
             activity = activity,
             alias = TogetherAdAlias.AD_INTER,
             listener = listener
         )
         adHelperInter?.load()
     }

    fun show(){
        adHelperInter?.show()
    }

    /**
     * 加载成功后立即显示
     */
    fun loadAndShow(activity: Activity,
                    listener: InterListener? = null){
        load(activity, object : InterListener {
            override fun onAdLoaded(providerType: String) {
                show()
            }

            override fun onAdClose(providerType: String) {
                listener?.onAdClose(providerType)
            }

            override fun onAdClicked(providerType: String) {
                listener?.onAdClicked(providerType)
            }

            override fun onAdExpose(providerType: String) {
                listener?.onAdExpose(providerType)
            }

            override fun onAdFailed(providerType: String, failedMsg: String?) {
                listener?.onAdFailed(providerType, failedMsg)
            }

            override fun onAdFailedAll(failedMsg: String?) {
                listener?.onAdFailedAll(failedMsg)
            }

            override fun onAdStartRequest(providerType: String) {
                listener?.onAdStartRequest(providerType)
            }
        })
    }
}